package com.ftg.learn.service.imple;

import com.ftg.learn.domain.EmployeeDomain;
import com.ftg.learn.mapper.EmplyeeMapper;
import com.ftg.learn.service.EmployeeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 业务处理类
 *
 * @author 布衣
 */
@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Resource
    EmplyeeMapper emplyeeMapper;

    public PageInfo<EmployeeDomain> list(String ename,Integer pageNum,Integer pageSize){
        //偏移量 ， 以及每页显示多少
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<EmployeeDomain> pageInfo = new PageInfo<>(emplyeeMapper.list(ename));
        return pageInfo;
    }

    @Override
    public Integer save(EmployeeDomain employeeDomain) {
        employeeDomain.setSex(employeeDomain.getSex()=="true"?"男":"女");
        return emplyeeMapper.save(employeeDomain);
    }

}
